//
//  ZH_MineTeacherTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/22.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MineTeacherTableViewCell.h"
@interface ZH_MineTeacherTableViewCell()
@property (nonatomic,weak)UIImageView *photoImage;
@property (nonatomic,weak)UILabel *titleLabel;
@property (nonatomic,weak)UILabel *contentLabel;
@property (nonatomic,weak)UIButton *typeButton;
@property (nonatomic,weak)UIButton *collectButton;
@end
@implementation ZH_MineTeacherTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_MineTeacherTableViewCell";
    ZH_MineTeacherTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_MineTeacherTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
    self.bottomLongLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.photoImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(15));
        make.left.equalTo(self.contentView).offset(FITSCALE(11));
        make.width.mas_equalTo(FITSCALE(72));
        make.height.mas_equalTo(FITSCALE(72));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-15));
    }];
    [self.typeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(20));
        make.right.equalTo(self.contentView).offset(FITSCALE(-12));
        make.width.mas_equalTo(FITSCALE(56));
        make.height.mas_equalTo(FITSCALE(22));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(25));
        make.left.equalTo(self.photoImage.mas_right).offset(FITSCALE(12));
        make.right.equalTo(self.typeButton.mas_left);
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.titleLabel.mas_bottom).offset(FITSCALE(18));
        make.left.right.equalTo(self.titleLabel);
        make.right.equalTo(self.contentView).offset(FITSCALE(-105));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-14));
    }];
//    [self.collectButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.typeButton.mas_bottom).offset(FITSCALE(25));
//        make.right.equalTo(self.contentView).offset(FITSCALE(-12));
//    }];
}
- (void)updataUI:(NSDictionary *)data{
    if (data) {
        [self.photoImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",SERVER_TEST,data[@"head"]]]];
        self.titleLabel.text = [NSString stringWithFormat:@"%@",data[@"nickname"]];
        self.contentLabel.text = [NSString stringWithFormat:@"￥%@/小时",data[@"price"]];
        NSString *string = [NSString stringWithFormat:@"%@",data[@"is_verify"]];
        if ([string isEqualToString:@"1"]) {
            [self.typeButton setTitle:@"已认证" forState:UIControlStateNormal];
        }
        else {
            [self.typeButton setTitle:@"未认证" forState:UIControlStateNormal];
        }
    }
}

#pragma mark - getter,setter
- (UIImageView *)photoImage{
    if (!_photoImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@""];
        image.backgroundColor = kFontColorRed;
        image.layer.cornerRadius = FITSCALE(36);
        image.layer.masksToBounds = YES;
        image.clipsToBounds = YES;
        [self.contentView addSubview:_photoImage = image];
    }
    return _photoImage;
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        UILabel *label = [UILabel createLabelWithText:@"机构名字..." font:kFontSize_28];
        [self.contentView addSubview:_titleLabel = label];
    }
    return _titleLabel;
}
- (UILabel *)contentLabel{
    if (!_contentLabel) {
        UILabel *label = [UILabel createLabelWithText:@"￥100/小时" font:kFontSize_34];
        label.textColor = [UIColor colorWithHexString:@"#F0302F"];
        [self.contentView addSubview:_contentLabel = label];
    }
    return _contentLabel;
}
- (UIButton *)typeButton{
    if (!_typeButton) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"已认证" target:self action:nil];
        button.backgroundColor = [UIColor colorWithHexString:@"#CBFFF8"];
        [button setTitleColor:[UIColor colorWithHexString:@"#00C9AE"] forState:UIControlStateNormal];
        button.layer.cornerRadius = FITSCALE(10);
        button.layer.masksToBounds = YES;
        button.clipsToBounds = YES;
        button.titleLabel.font = kFontSize_26;
        [self.contentView addSubview:_typeButton = button];
    }
    return _typeButton;
}
- (UIButton *)collectButton{
    if (!_collectButton) {
        UIButton *button = [UIButton createButtonWithTitle:@"" normalImage:@"icon_fllow" pressImage:@"icon_fllow_selected" target:self action:nil];
        [self.contentView addSubview:_collectButton = button];
    }
    return _collectButton;
}
@end
